﻿using System.Collections.Generic;

namespace Nickel
{

    /// <summary>
    /// String list extension
    /// </summary>
    public class Words : List<string>
    {

        /// <summary>
        /// Perform join on this list's strings
        /// </summary>
        public string Join()
        {

            // Call other override
            return Join("");

        }

        /// <summary>
        /// Perform join on this list's strings
        /// </summary>
        /// <param name="separator">Separator</param>
        /// <returns>Joined string</returns>
        public string Join(string separator)
        {

            // Initialize output
            string output = string.Empty;

            // Iterate through words
            for (int i = 0; i < Count; i++)
            {

                // Add word to output
                output += this[i];

                // Add separator if this is not the last one
                if (i < Count - 1) 
                    output += separator;

            }

            // Return output
            return output;

        }

    }

}
